﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Generator.Test
{
    public static class StringExtensions
    {
        //1.<#=PropertyVirtualModifier(Accessibility.ForProperty(edmProperty))  #>   // public virtual
        //2.<#=code.Escape(edmProperty.TypeUsage)#>   //string
        //3.<#=code.Escape(edmProperty)#> //DNI_TITLE
        //4.<#=code.SpaceAfter(Accessibility.ForGetter(edmProperty))#>
        //5.<#=code.FieldName(edmProperty)#>  //_dNI_TITLE
        //6.<#=code.SpaceAfter(Accessibility.ForSetter(edmProperty))#>
        public static string ToClass(this string arg)
        {
            return ConverToPas(arg);
        }
        public static string ToPo(this string arg)
        {
            return ConverToPas(arg);
        }

        private static string ConverToPas(string arg)
        {
            if (string.IsNullOrEmpty(arg))
                return "";

            arg = arg.ToLower();
            if (arg.IndexOf("_") != -1)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                string[] names = arg.Split('_');
                if (names != null && names.Length > 0)
                {
                    for (int i = 1; i < names.Length; i++)
                    {
                        sb.Append(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(names[i]));
                    }
                }
                return sb.ToString();
            }
            return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(arg);
        }
    }
}
